how to remove a index from a string in cpp

160

// CPP code to illustrate
// erase(size_type idx, size_type len )
#include <iostream>
#include <string>
using namespace std;
 
// Function to demo erase
void eraseDemo(string str)
{
    // Deletes 4 characters from index number 1
    str.erase(1, 4);
 
    cout << "After erase : ";
    cout << str;
}
 
// Driver code
int main()
{
    string str("Hello World!");
 
    cout << "Before erase : ";
    cout << str << endl;
    eraseDemo(str);
 
    return 0;
}

Comments

Submit
0 Comments

More Questions

c++ vector printstring to char array c++ remove element by index from vector c++
cpp print vectorchange int to string cpp c++ throw exception
flutter convert datetime in day of monthflutter datetime format removing a character from a string in c++
DateFormat in Flutterconvert string to char c++ integer to string c++
create and write to a file c++19remove value from vector c++ conda list envs
c++ map iteratorvariadic template in c++ Lucky Four codechef solution in c++
throw exception c++c++ cin accept only numbers c++ take n number from the user and store them in array and get the max, min number of them and also find the average-summation of these numbers
change integer to string c++binary exponentiation modulo m initialize 2d vector as 0
cpp map containsc++ get file content for c++
char vector to string c++2d vector initialization in cpp mt19937 example c++
what is require to run min max function on linux in cppget first element of set c++ CPP Find options passed from command line
Max element in an array with the index in c++qt rotate qimage set elements to 42 back
Patrick and Shopping codeforces in c++boundary traversal of binary tree how to remove a index from a string in cpp
convert vector into array c++Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volod type defination in C++
hola mundo c++